program xxx (datafath, datamoth); uses Wincrt; {mc is ("max") nr. of categories in data file} const mc = 99; var max,min,yy,sumwdif,sumwcom, simcatws, simnum, sim: real; i,j,f,m,N, namfath, nammoth: integer; wo, wy: array[1..(mc+1)] of real; {mc+1th category is not data but is set to 999, so as to indicate end of data file} op, datafath, datamoth: text; {If you use this program often, and always have to rename files as datamoth, datafath, then better call them, e.g., o (fath, fixed for comparisons) and c (comparand). I do not do that in this file because then these things would be hard to change through find/replace later.} begin assign(op, '\home\wakker\simreprt'); rewrite(op); {\simreprt will be the output file.} assign(datafath, '\home\wakker\datafath'); {\home\wakker\datafath is one data input file.} assign(datamoth, '\home\wakker\datamoth'); {\home\wakker\datamoth is another data input file.} reset(datafath); {puts data file datafath at beginning} readln(datafath, namfath); {reads first line of data file, the subj. nr} reset(datamoth); {puts data file datafath at beginning} readln(datamoth, nammoth); {the data file datafath is now at line two, where we left it. There we read next data.} readln(datafath, N); {reads N the upperbound for the # of categories, so the subjective index of importance of the frequentist info, at the 2nd line of data file.} readln(datamoth); {to stay at same rythm in other data file} readln(datafath, min); readln(datafath, max); readln(datamoth); readln(datamoth); {to stay at same rythm in other data file} for i:=1 to mc do begin wo[i] := min; wy[i] := min; end; {wo[i] is the seriousness weight of participant father for category i} {wy[i] is the seriousness weight of participant mother category i} {We start by setting the default value equal to zero, or whatever min is, for them all.} reset(datafath); {puts data file datafath at beginning again} readln(datafath);{moves data file datafath to line 2} readln(datafath);{moves data file datafath to line 3} readln(datafath);{moves data file datafath to line 4} readln(datafath);{moves data file datafath to line 5} {onderstaande weg om reden toegelicht bij datamoth. i:=0; repeat i := i+1; readln(datafath, wo[i]);} {defining the seriousness weights wo[i]} { until wo[i] = 999; } {so it stops when 999 is found, leaving others at default value 0/min.} { wo[i] := min;} {Should not have a value 999 hanging around!} yy := 0; for i:=1 to mc do begin readln(datafath, wo[i]); yy := yy + wo[i] - min; end; If abs(yy - 0) < 0.00001 then begin writeln('WARNING: ALL CATEGORIES FOR PARTICIPANT',namfath:3, ' ARE ABSENT.'); writeln(op, 'WARNING: ALL CATEGORIES FOR PARTICIPANT',namfath:3, ' ARE ABSENT.'); end; {datamoth is treated the same as datafath} reset(datamoth); readln(datamoth); readln(datamoth); readln(datamoth); readln(datamoth); yy := 0; for i:=1 to mc do begin readln(datamoth, wy[i]); yy := yy + wy[i] - min; end; If abs(yy - 0) < 0.00001 then begin writeln('WARNING: ALL CATEGORIES FOR PARTICIPENT',nammoth:3, ' ARE ABSENT.'); writeln(op, 'WARNING: ALL CATEGORIES FOR PARTICIPENT',nammoth:3, ' ARE ABSENT.'); end; { Onderstaande zou prettig zijn omdat files dan niet precies (mc = ) 99 categorien zouden hoeven hebben. Helaas gaf het hele vreemde errors in oktober 2002. Als ik een writeln(op, 'test') hierachter deed dan verdomde de computer dat gewoon, en gaf error. Als ik die writeln(op, 'test') hiervoor deed dan deed de computer het wel. Voor zover ik kan zien behandelde ik datafath en datamoth geheel hetzelfde, dus waarom het hier gebeurde begreep ik echt niet. i:=0; repeat i := i+1; readln(datamoth, wy[i]); until wy[i] = 999; wy[i] := min; } sumwdif := 0; for i:=1 to mc do begin sumwdif := sumwdif + abs(wo[i]-wy[i])/(max-min); end; j := 0; {j is to become nr. of categories showing up for both participants} for i:=1 to mc do begin if (abs(wo[i] - min) > 0.00001) and (abs(wy[i] - min) > 0.00001) then j := j+1; {weights are reals so rounding might destroy equality; therefore, safer to take as not too different from the min value that indicates that they were not brought up.} end; f := 0; {f is to become nr. of categories showing up for father, not for mother} for i:=1 to mc do begin if (abs(wo[i] - min) > 0.00001) and (abs(wy[i] - min) < 0.00001) then f := f+1; end; m := 0; {m is to become nr. of categories showing up for mother person, not for father} for i:=1 to mc do begin if (abs(wo[i] - min) < 0.00001) and (abs(wy[i] - min) > 0.00001) then m := m+1; end; writeln('Number of joint categories (denoted j) =', j:3,'.'); writeln('Number of father/not-mother categories (denoted f) =', f:3,'.'); writeln('Number of mother/not-father categories (denoted m) =', m:3,'.'); sumwcom := j + f + m - sumwdif; writeln(''); simcatws := sumwcom/(j+f+m); writeln('N, the upper bound for # of categories, is ', N:3, '.'); writeln(' '); writeln('The similarity based only on the seriousness weights'); writeln('for the categories brought up by one or both is'); writeln(simcatws:5:4,'.'); simnum := (sqrt(j/N) + 1 - abs(sqrt(f/N) - sqrt(m/N)))/2; writeln(' '); writeln('The similarity for the number of categories, without'); writeln('consideration of the seriousness weights, is'); writeln(simnum:5:4,'.'); sim := (simcatws + simnum)/2; writeln(' '); writeln('The total similarity index between participant #', namfath:3, ' and participant #',nammoth:3); writeln('is'); writeln(' '); writeln(' ', sim:5:4,'.'); writeln(''); writeln(''); writeln('Output can be found in the file c:\home\wakker\simreprt.'); {Onderstaande copieert bovenstaande maar dan voor schrijving in file \xx. ================================================== ===================================================} writeln(op, 'The Similarity of Two Participants'); writeln(op, ' Peter P. Wakker, December 2009'); writeln(op, ''); writeln(op, 'Number of joint categories (denoted j) =', j:3,'.'); writeln(op, 'Number of father/not-mother categories (denoted f) =', f:3,'.'); writeln(op, 'Number of mother/not-father categories (denoted m) =', m:3,'.'); writeln(op, ''); writeln(op, 'N, the upper bound for # of categories, is ', N:3, '.'); writeln(op, ' '); writeln(op, 'The similarity based only on the seriousness weights'); writeln(op, 'for the categories brought up by one or both is'); writeln(op, simcatws:5:4,'.'); writeln(op, ' '); writeln(op, 'The similarity for the number of categories, without'); writeln(op, 'consideration of the seriousness weights, is'); writeln(op, simnum:5:4,'.'); writeln(op, ' '); writeln(op, ' '); writeln(op, 'The total similarity index between participant #', namfath:3, ' and participant #',nammoth:3); writeln(op, 'is'); writeln(op, ' '); writeln(''); writeln(op, ' ', sim:5:4,'.'); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); writeln(op, ' '); end.